var contitleArticle=document.getElementsByClassName('con-title-Article')[0];
var contitleApp=document.getElementsByClassName('con-title-App')[0];
var conmainArticle =document.getElementsByClassName('con-main-Article')[0];
var conmainApp=document.getElementsByClassName('con-main-App')[0];
contitleArticle.ontouchstart=function () {
   this.classList.add("on");
    conmainArticle.classList.add("on");
    contitleApp.classList.remove("on");
    conmainApp.classList.remove("on")
}
contitleApp.ontouchstart=function () {
    this.classList.add("on");
    conmainApp.classList.add("on");
    contitleArticle.classList.remove("on");
    conmainArticle.classList.remove("on")
}
//轮播
var mySwiper = new Swiper('.swiper-container', {
    autoplay: 1800,//可选选项，自动滑动
    speed:300,//运动速度
    //autoplayDisableOnInteraction:false,//用户操作swiper之后,是否禁止autoplay，默认true 停止
    touchAction:20, //允许触发拖动的角度值，默认45度，即使触摸方向不是完全水平也可拖动slide
    scrollbar:'.swiper-scrollbar',
    scrollbarHide:false,

});
//获取首页文章
function formatterDateTime() {
    var date=new Date()
    var month=date.getMonth() + 1
    var datetime = date.getFullYear()
        + ""// "年"
        + (month >= 10 ? month : "0"+ month)
        + ""// "月"
        + (date.getDate() < 10 ? "0" + date.getDate() : date
            .getDate())
        + ""
        + (date.getHours() < 10 ? "0" + date.getHours() : date
            .getHours())
        + ""
        + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
            .getMinutes())
        + ""
        + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
            .getSeconds());
    return datetime;
}

$.ajax({
    type: 'post',
    url: 'http://route.showapi.com/181-1',
    dataType: 'json',
    data: {
        "showapi_timestamp": formatterDateTime(),
        "showapi_appid": '67695', //这里需要改成自己的appid
        "showapi_sign": '49495bb2af264a45a65b4d76a508e3a5',  //这里需要改成自己的应用的密钥secret
        "num":"10",
        "rand":"1",

    },

    error: function(XmlHttpRequest, textStatus, errorThrown) {
        alert("文章列表加载失败!");
    },
    success: function(result) {
        var data=result.showapi_res_body.newslist; //console变量在ie低版本下不能用
        Createnewslist(data);
    }
});
var newsList=document.getElementsByClassName('newsList')[0];
function Createnewslist(data) {

    var allLi=document.createDocumentFragment();//节点碎片整合

    for (var key in data){
       // console.log( data[key])
        var oli=document.createElement('li');

        oli.innerHTML=' <a href="'+data[key].url+'">' +
            '<div class="Preview-map"><img src="'+data[key].picUrl+'"/></div>'+
            '<div class="Preview-title">'+ data[key].title +'</div>'+
            '<div class="arrow"><div></div></div>' +
            '</a>';
        allLi.appendChild(oli);
    }

    newsList.appendChild(allLi);
}





























